﻿/**
 * Sound.cs - Sound subsystem,  to hide SDL_mixer
 * 
 * Part of BoulderDAM - A BoulderDash clone using C# and SDL
 * Nacho Cabanes & students of DAM IES San Vicente, 2014
 * 
 * Revisions
 * #     Date         Creator, changes
 * ----  -----------  -------------------------------------------------------
 * 0.01  02-apr-2014  Nacho Cabanes: Skeleton
 * 0.02  03-apr-2014  Jose Luis Valdelvira, Marco Uceda, Jesus Sagra: Class sound
 *                                      implemented
 */

using System;
using Tao.Sdl;

namespace Boulder
{
    class Sound
    {
        IntPtr songPointer;
        IntPtr auxSound;
        protected bool enable;

        public Sound(string fileName)
        {
            songPointer = SdlMixer.Mix_LoadMUS(fileName);
            auxSound = SdlMixer.Mix_LoadWAV(fileName);
            enable = true;
        }
        public void PlayOnce()
        {
            if (IsEnabled())
                SdlMixer.Mix_PlayMusic(songPointer, 1);
        }

        public void PlayAsBackground()
        {
            if(IsEnabled())
                SdlMixer.Mix_PlayMusic(songPointer, -1);
        }

        // Mute sound
        public void Halt()
        {
            SdlMixer.Mix_HaltMusic();

        }

        public void Enable()
        {
            enable = true;
        }

        public void Disable()
        {
            enable = false;
        }

        public bool IsEnabled()
        {
            return enable;
        }

    }
}
